package itesm.mx;

import android.os.Bundle;
import android.widget.*;

public class FlagQuizActivity extends QuizActivity {
	protected int[] flags = {
		R.drawable.g1_andorra_flag,
		R.drawable.g1_armenia_flag,
		R.drawable.g1_colombia_flag,
		R.drawable.g1_ecuador_flag,
		R.drawable.g1_moldova_flag,
		R.drawable.g1_romania_flag,
		R.drawable.g1_venezuela_flag,
		R.drawable.g2_bulgaria_flag,
		R.drawable.g2_cote_d_ivoire_flag,
		R.drawable.g2_hungary_flag,
		R.drawable.g2_india_flag,
		R.drawable.g2_iran_flag,
		R.drawable.g2_ireland_flag,
		R.drawable.g2_italy_flag,
		R.drawable.g2_mexico_flag,
		R.drawable.g2_niger_flag,
		R.drawable.g2_oman_flag,
		R.drawable.g2_tajikistan_flag,
		R.drawable.g3_australia_flag,
		R.drawable.g3_chile_flag,
		R.drawable.g3_cuba_flag,
		R.drawable.g3_liberia_flag,
		R.drawable.g3_malaysia_flag,
		R.drawable.g3_new_zealand_flag,
		R.drawable.g3_north_korea_flag,
		R.drawable.g3_panama_flag,
		R.drawable.g3_philippines_flag,
		R.drawable.g3_samoa_flag,
		R.drawable.g3_united_states_flag
	};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.imagequiz);
		countries = getResources().getStringArray(R.array.flags_countries);
		
		nextQuestion();
		displayQuestion();
	}
	
	protected void displayQuestion() {
		ImageView[] answerButtons = {
			(ImageView) findViewById(R.id.answer1),
			(ImageView) findViewById(R.id.answer2),
			(ImageView) findViewById(R.id.answer3),
			(ImageView) findViewById(R.id.answer4)
		};
		
		for (int i = 0; i < answerButtons.length; i++) {
			answerButtons[i].setImageResource(flags[currentQuestion[i]]);
			answerButtons[i].setOnClickListener(this);
		}
		
		String questionText = getResources().getString(R.string.flags_question);
		questionText += " ";
		questionText += countries[currentAnswer];
		questionText += getResources().getString(R.string.question_terminator);
		
		TextView question = (TextView) findViewById(R.id.question);
		question.setText(questionText);
	}
	
	@Override
	protected void onFinish(int score) {
		updateStats(AndroidProject.QUIZ_FLAGS, score);
	}
	protected int getId(){return flags[currentAnswer];}
}
